package com.ruoyi.doctor.service.impl;


import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.doctor.domain.DoctorPatientHistory;
import com.ruoyi.doctor.mapper.DoctorPatientHistoryMapper;
import com.ruoyi.doctor.service.DoctorPatientHistoryService;
import com.ruoyi.system.domain.SysCheck;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 历史病例Service业务层处理
 *
 * @author ruoyi
 * @date 2022-11-13
 */
@Service
public class DoctorPatientHistoryServiceImpl implements DoctorPatientHistoryService
{
    @Autowired
    private DoctorPatientHistoryMapper doctorPatientHistoryMapper;

    /**
     * 查询历史病例
     *
     * @param historyId 历史病例主键
     * @return 历史病例
     */
    @Override
    public DoctorPatientHistory selectDoctorPatientHistoryByHistoryId(Long historyId)
    {
        return doctorPatientHistoryMapper.selectDoctorPatientHistoryByHistoryId(historyId);
    }

    /**
     * 查询历史病例列表
     *
     * @param doctorPatientHistory 历史病例
     * @return 历史病例
     */
    @Override
    public List<DoctorPatientHistory> selectDoctorPatientHistoryList(DoctorPatientHistory doctorPatientHistory)
    {
        return doctorPatientHistoryMapper.selectDoctorPatientHistoryList(doctorPatientHistory);
    }

    /**
     * 新增历史病例
     *
     * @param doctorPatientHistory 历史病例
     * @return 结果
     */
    @Override
    public int insertDoctorPatientHistory(DoctorPatientHistory doctorPatientHistory)
    {
        doctorPatientHistory.setCreateTime(DateUtils.getNowDate());
        //生成病例编码，格式是SYL+时间戳
        doctorPatientHistory.setHistoryNumber("SYL"+ System.currentTimeMillis());
        return doctorPatientHistoryMapper.insertDoctorPatientHistory(doctorPatientHistory);
    }

    /**
     * 修改历史病例
     *
     * @param doctorPatientHistory 历史病例
     * @return 结果
     */
    @Override
    public int updateDoctorPatientHistory(DoctorPatientHistory doctorPatientHistory)
    {
        doctorPatientHistory.setUpdateTime(DateUtils.getNowDate());
        return doctorPatientHistoryMapper.updateDoctorPatientHistory(doctorPatientHistory);
    }

    /**
     * 批量删除历史病例
     *
     * @param historyIds 需要删除的历史病例主键
     * @return 结果
     */
    @Override
    public int deleteDoctorPatientHistoryByHistoryIds(Long[] historyIds)
    {
        return doctorPatientHistoryMapper.deleteDoctorPatientHistoryByHistoryIds(historyIds);
    }

    /**
     * 删除历史病例信息
     *
     * @param historyId 历史病例主键
     * @return 结果
     */
    @Override
    public int deleteDoctorPatientHistoryByHistoryId(Long historyId)
    {
        return doctorPatientHistoryMapper.deleteDoctorPatientHistoryByHistoryId(historyId);
    }
    /**
     *
     * @param doctorPatientHistory 根据患者主键查询患者历史病历
     * @return 返回历史病历
     */
    @Override
    public List<DoctorPatientHistory> selectListByPatientId(DoctorPatientHistory doctorPatientHistory) {
        return doctorPatientHistoryMapper.selectListByPatientId(doctorPatientHistory);
    }
}

